/**
 * @License: (C) Copyright 2013-2022
 * @Contact: abcque@outlook.com
 * @IDE: IntelliJ IDEA
 * @Encoding: utf-8
 * @Project: st2214st2215
 * @Package: PACKAGE_NAME
 * @File: ClassLoaderTest.java
 * @Time: 2023/5/30 15:55
 * @Author: abcque
 * @Description:
 * @Modifier:
 * @ModifyDate:
 * @ModifyRemark:
 */
public class ClassLoaderTest {
    public static void main(String[] args) {
        // 获取系统的类加载器
        ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
        System.out.println(systemClassLoader);

        // 获取系统类加载器的父类，即 ExtClassLoader
        ClassLoader extClassLoader = systemClassLoader.getParent();
        System.out.println(extClassLoader);

        // 获取 扩展类加载器的父类，
        ClassLoader parent = extClassLoader.getParent();
        System.out.println(parent);

        try {
            ClassLoader classLoaderTest = Class.forName("ClassLoaderTest").getClassLoader();
            System.out.println(classLoaderTest);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        try {
            ClassLoader classLoader = Class.forName("java.lang.Object").getClassLoader();
            System.out.println(classLoader);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }
}
